@extends('home.layout.base')
@section('scripts')
    <script>
        $(function () {
            let app = new Vue({
                el: '#app',
                data: function() {
                    return {
                        listData: [],
                        pageData: null,
                        hasData: true, //加载更多开关
                        noData: false, //没有数据开关
                        loading: false,//加载loading开关
                        params:{page : 1, cateid : 0, catepid : 0,position:1},
                    }
                },
                created(){
                    this.list();
                },
                methods: {
                    list() {
                        let that = this;
                        this.hasData = false;
                        this.loading = true;
                        setTimeout(()=>{
                            $.get("",this.params,function(res){
                                that.pageData = res.data;
                                if(that.params.page == 1){
                                    that.listData = res.data.data;
                                }else{
                                    that.listData = that.listData.concat(res.data.data);
                                }
                                that.loading = false;
                                if(that.params.page == that.pageData.last_page){
                                    that.noData = true;
                                    that.hasData = false;
                                }else{
                                    that.noData = false;
                                    that.hasData = true;
                                }
                                that.params.page ++;
                            })
                        },300);
                    },
                    info(id) {
                        window.location.href = ""+'?id='+id;
                    },
                    paginate(){
                        this.hasData = false;
                        this.list();
                    }
                }
            });
        })


    </script>
@endsection
@section('content')
    <div class="container main">
        <div class="row">
            <div id="app" v-cloak></div>
        </div>
    </div>
@endsection

